import Vue from 'vue'
import axios from 'axios' //引入axios
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/' //配置请求根路径
// axios请求拦截器对请求发送前进行预处理
// 在 request 拦截器中展示进度条
axios.interceptors.request.use(config => {
  NProgress.start()
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})

// 在 response 拦截器中隐藏进度条
axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})

Vue.prototype.$http = axios //将axios挂载到vue原型


import App from './App.vue'
import router from './router'
import store from './store'
import './assets/css/global.css' //引入全局样式表
import './assets/iconfont/iconfont.css' //引入阿里字体图标
import TreeTable from 'vue-table-with-tree-grid' //导入第三方表格插件
import vueQuillEditor from 'vue-quill-editor'  // 导入第三方富文本编辑器插件
// 导入富文本编辑器样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

import NProgress from 'nprogress'
import 'nprogress/nprogress.css'




import {
  Button,
  Form,
  FormItem,
  Input,
  Message,
  Container,
  Aside,
  Header,
  Main,
  Menu,
  Submenu,
  MenuItem,
  Breadcrumb,
  BreadcrumbItem,
  Card,
  Col,
  Row,
  Table,
  TableColumn,
  Switch,
  Tooltip,
  Pagination,
  Dialog,
  MessageBox,
  Tag,
  Tree,
  Select,
  Option,
  Cascader,
  Alert,
  TabPane,
  Tabs,
  Steps,
  Step,
  Checkbox,
  CheckboxGroup,
  Upload
} from 'element-ui' //引入 element-ui 相关组件
// 使用 element-UI 相关组件
Vue.use(Button)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(Input)
Vue.prototype.$message = Message
Vue.use(Container)
Vue.use(Aside)
Vue.use(Header)
Vue.use(Main)
Vue.use(Menu)
Vue.use(Submenu)
Vue.use(MenuItem)
Vue.use(Breadcrumb)
Vue.use(BreadcrumbItem)
Vue.use(Card)
Vue.use(Col)
Vue.use(Row)
Vue.use(Table)
Vue.use(TableColumn)
Vue.use(Switch)
Vue.use(Tooltip)
Vue.use(Pagination)
Vue.use(Dialog)
Vue.prototype.$confirm = MessageBox.confirm
Vue.use(Tag),
  Vue.use(Tree),
  Vue.use(Select),
  Vue.use(Option),
  Vue.use(Cascader),
  Vue.use(Alert),
  Vue.use(Tabs),
  Vue.use(TabPane),
  Vue.use(Steps),
  Vue.use(Step),
  Vue.use(Checkbox)
Vue.use(CheckboxGroup)
Vue.use(Upload)

Vue.component('treeTable', TreeTable) //注册使用第三方表格插件
Vue.use(vueQuillEditor)  // 使用富文本编辑器插件

// 事件格式化过滤器
Vue.filter('dataFormate', function () {
  let dt = new Date();
  let y = dt.getFullYear();
  let m = (dt.getMonth() + 1 + '').padStart(2, '0');
  let d = (dt.getDate() + '').padStart(2, '0');
  let hh = (dt.getHours() + '').padStart(2, '0');
  let mm = (dt.getMinutes() + '').padStart(2, '0');
  let ss = (dt.getSeconds() + '').padStart(2, '0');

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
